﻿/*
 * Created by SharpDevelop.
 * User: CrOnO
 * Date: 03/11/2011
 * Time: 08:25 a.m.
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using Business_Entity;

namespace DAOFactory
{
	/// <summary>
	/// Description of DAOTipoServicio.
	/// </summary>
	public class DAOTipoServicio
	{
		public DAOTipoServicio()
		{
		}
		
		public List<BETipoServicio> completarTipoServicio()
		{
			SqlCommand cmd = new SqlCommand("VENTAS_OBTENER_TIPO_SERV_L", ConnectionManager.getConnection());
			cmd.CommandType = CommandType.StoredProcedure;
				
			SqlDataReader amd = cmd.ExecuteReader();
			List<BETipoServicio> lista = new List<BETipoServicio>();
			
			if (amd.HasRows) 
			{
				lista.Add(new BETipoServicio(-1,"<Seleccionar>"));
				
				while(amd.Read())
				{
					BETipoServicio tipoServ = new BETipoServicio();
					
					try
					{
						tipoServ.Id= Int32.Parse(amd[0].ToString());
						tipoServ.Nombre = amd[1].ToString();
						lista.Add(tipoServ);
					}
					catch
					{
						System.Windows.Forms.MessageBox.Show("Error al obtener Tipo de Documento","Error");
						amd.Close();
						return null;
					}
				}
				amd.Close();
				
				return lista;
			}
			else
			{
				amd.Close();				
				return null;
			}
		}
	}
}
